package com.example.iotmanagerment26;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;





@Component
public class TestSchedule {
/*
    @Scheduled(fixedRate = 10 * 1000, initialDelay = 5000)  //采用间隔调度，每10秒执行一次
    public void runJoba(){ //定义一个执行的任务
        System.out.println("[*******MyTaskA -- 间隔调度 ******]"+
                new SimpleDateFormat("yyy-MM-dd HH:mm:ss.SSS").format(new Date()));
    }
*/

    @Autowired
    OkHttpExample1  obj;

    @Scheduled(cron = "*/10 * * * * ?")
    public void runJobb0() {
        System.out.println("[*******MyTaskB -- 间隔调度 ******]"+
                new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date()));
        try {
            obj.sendGETSync();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
